home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cpostsrc.arj / LIST.H < prev    next >
C/C++ Source or Header  |  1992-08-08  |  3KB  |  88 lines

  1. /*------------------------------------------------------------------
  2.  * list.h : list functions
  3.  *------------------------------------------------------------------
  4.  * 10-19-88 originally by Patrick J. Mueller
  5.  * 08-07-92 fixed up by Patrick J. Mueller
  6.  *------------------------------------------------------------------*/
  7.  
  8. #if !defined(LIST_H_INCLUDED)
  9. #define LIST_H_INCLUDED
  10.  
  11. typedef int  ListCompareFunc (void *pItem1, void *pItem2);
  12. typedef void ListIterateFunc (void *pItem,  void *pUserData);
  13. typedef void ListNoMemFunc   (void);
  14.  
  15. typedef struct ListNode ListNode;
  16. struct ListNode
  17.    {
  18.    void     *pItem;
  19.    ListNode *next;
  20.    };
  21.  
  22. typedef struct List
  23.    {
  24.    int              count;
  25.    int              itemSize;
  26.    ListNode        *head;
  27.    ListCompareFunc *cmpFunc;
  28.    ListNoMemFunc   *memFunc;
  29.    } List;
  30.  
  31. /*------------------------------------------------------------------
  32.  * create a list
  33.  *------------------------------------------------------------------*/
  34. List *ListCreate(
  35.    int              itemSize,
  36.    ListCompareFunc *cmpFunc,
  37.    ListNoMemFunc   *memFunc
  38.    );
  39.  
  40. /*------------------------------------------------------------------
  41.  * destroy a list
  42.  *------------------------------------------------------------------*/
  43. void ListDestroy(
  44.    List *list
  45.    );
  46.  
  47. /*------------------------------------------------------------------
  48.  * count items in list
  49.  *------------------------------------------------------------------*/
  50. int ListCount(
  51.    List *list
  52.    );
  53.  
  54. /*------------------------------------------------------------------
  55.  * find an item
  56.  *------------------------------------------------------------------*/
  57. void *ListFind(
  58.    List *list,
  59.    void *pItem
  60.    );
  61.  
  62. /*------------------------------------------------------------------
  63.  * add an item to the list
  64.  *------------------------------------------------------------------*/
  65. void *ListAdd(
  66.    List *list,
  67.    void *pItem
  68.    );
  69.  
  70. /*------------------------------------------------------------------
  71.  * delete item from list
  72.  *------------------------------------------------------------------*/
  73. void ListDelete(
  74.    List *list,
  75.    void *pItem
  76.    );
  77.  
  78. /*------------------------------------------------------------------
  79.  * iterate through list
  80.  *------------------------------------------------------------------*/
  81. void ListIterate(
  82.    List            *list,
  83.    ListIterateFunc *pIterateFunc,
  84.    void            *pUserData
  85.    );
  86.  
  87. #endif
  88.